import * as qs from "qs";
import * as Config from "@/config";
import { post } from "@/api/httpRequest";

/**
 * 图谱生成相关API
 * ！！！http请求需要调用 httpRequest下方法 其中封装了登录状态检测逻辑
 */

const BASE_URI = Config.HTTP_SERVER + "/kgqa";

/**
 * 发送问题字符串，获取答案
 * @param question
 * @param success
 * @param error
 * @param final
 * @returns {*}
 */
export function askAPI(question, success, error, final) {
  return post(
    BASE_URI + "/ask",
    qs.stringify(question),
    success,
    error,
    final,
    {
      headers: { "content-type": "application/x-www-form-urlencoded" }
    }
  );
}

/**
 * 获取问题推荐
 * @param uri
 * @param success
 * @param error
 * @param final
 */
export function askForRecommendAPI(uri, success, error, final) {
  post(
    BASE_URI + "/askForRecommend",
    qs.stringify(uri),
    success,
    error,
    final,
    {
      headers: { "content-type": "application/x-www-form-urlencoded" }
    }
  );
}
